package ptij.verifier.test.causality;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.*;
import ptolemy.data.type.*;

public class test2 extends TypedAtomicActor {

   public test2(CompositeEntity container, String Name) throws
           NameDuplicationException, IllegalActionException  {
       super(container, Name);      
       
       plus = new TypedIOPort(this, "plus", true, false);
       input1 = new TypedIOPort(this, "input1", true, false);
       
       output = new TypedIOPort(this, "output", false, true);
       output2 = new TypedIOPort(this, "output2", false, true);
   }

   public TypedIOPort plus;
   public TypedIOPort input1;
      
   public TypedIOPort output;
   public TypedIOPort output2;
   

   public void fire() throws IllegalActionException {
   
        if(plus.hasToken(0)) {	
	    output.broadcast(new Token());
	}
	
	if(input1.hasToken(0)) {
  	    IntToken it = (IntToken) input1.get(0);
	    int value = constant(it.intValue());
	    
	    output2.broadcast(new IntToken(value));	   
	}
	
   }
   
   private int constant(int n) {
      return  n * 10;
   }
   
	
   
}
